#ifndef ARTICLEFETCHER_H
#define ARTICLEFETCHER_H

#include <QObject>

class QNetworkReply;
class QNetworkAccessManager;
class ArticleFetcher : public QObject
{
    Q_OBJECT
public:
    explicit ArticleFetcher(QObject *parent = nullptr);

    // 设置请求模式（同步或异步）
    void setSyncMode(bool sync);

    void fetchArticleById(uint articleID);

signals:
    void articleFetched(const QJsonObject& article);
    void fetchFailed(const QString& error);

private slots:
    void onRequestFinished(QNetworkReply* reply);


private:
    QNetworkAccessManager* httpManager;
    bool isSync; // 请求模式标志位
};

#endif // ARTICLEFETCHER_H
